Contents

我们知道,在Percona XtraBackup执行增量恢复的时候有一步是加参数redo-only,如果不加这个参数,后面的增量是无法合并的。关于这个参数的作用,Percona XtraBackup官方文档的说明如下:

--redo-only
This option should be used when preparing the base full backup and when merging all incrementals except the last one. It is passed directly to xtrabackup’s xtrabackup --apply-log-only option. This forces xtrabackup to skip the “rollback” phase and do a “redo” only. This is necessary if the backup will have incremental changes applied to it later. See the xtrabackup documentation for details.

The xtrabackup –prepare step for incremental backups is not the same as for normal backups. In normal backups, two types of operations are performed to make the database consistent: committed transactions are replayed from the log file against the data files, and uncommitted transactions are rolled back. You must skip the rollback of uncommitted transactions when preparing a backup, because transactions that were uncommitted at the time of your backup may be in progress, and it’s likely that they will be committed in the next incremental backup. You should use thextrabackup –apply-log-only option to prevent the roll back phase.

Warning: Ifyoudonotusethextrabackup –apply-log-onlyoptiontopreventtherollbackphase,then your incremental backups will be useless. After transactions have been rolled back, further incremental backups cannot be applied.

大致意思是,redo-only除最后一次增量备份外,前面的增量备份在合并的时候都需要加上这个参数,即只进行前滚,不回滚,在备份进行时有事务未提交,很可能在下次增量备份的时候提交。如果执行了回滚,后面的备份将无法使用。

我们知道,redo是物理日志,记录数据库页的改变,全备事务未提交,redo只写了一半的事务数据,假使是个大事务,需要写多个数据页,前M个数据页已写完,事务还没提交,增备的时候写完后面N个数据页,这样完整的事务是M+N的数据页,由于前M个数据页LSN未更新,增备的时候是不会备份这M个数据页的,如果应用undo,这样全备的M个数据页就会被回滚丢失,完整的事务就不是M+N个数据页了,只有增备的N个数据页,这样就丢失了M个数据页的数据。

Contents